package org.marsdonne.audits;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

/**
 * 身份识别事件
 */
@Getter
@Setter
public class Identified implements Serializable {
    public enum Action {
        Found, //发掘(个人)用户, 应该只发生一次，但不做技术限制
        SignOn, //签署用户协议，首次或者协议更新后
        Authenticate, //认证，每次接入时的身份识别
        Authorize, //授权，根据用户协议，被授予的用户权益时
        Cancel, //解约/注销身份
    }

    private String user;
    private Action action;
    private Date dateIdentified;
    private JsonNode additions;

    public Identified(String user, Action action, JsonNode additions) {
        this.user = user;
        this.action = action;
        this.dateIdentified = new Date();
        this.additions = additions;
    }

    public Identified(Action action, JsonNode additions) {
        this.action = action;
        this.dateIdentified = new Date();
        this.additions = additions;
    }
}
